using Net35.Xrm.Sdk.Query;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Net35.Xrm.Sdk.Linq
{
	internal sealed class PagedItemCollection<TSource> : PagedItemCollectionBase, IEnumerable<TSource>, IEnumerable, IEnumerator<TSource>, IEnumerator, IDisposable
	{
		private TSource current;
		private IEnumerator<TSource> enumerator;
		private IEnumerable<TSource> source;
		public TSource Current
		{
			get
			{
				return this.current;
			}
		}
		object IEnumerator.Current
		{
			get
			{
				return this.Current;
			}
		}
		public PagedItemCollection(IEnumerable<TSource> source, QueryExpression query, string pagingCookie, bool moreRecords) : base(query, pagingCookie, moreRecords)
		{
			this.source = source;
		}
		public PagedItemCollection<TSource> Clone()
		{
			return new PagedItemCollection<TSource>(this.source, base.Query, base.PagingCookie, base.MoreRecords);
		}
		public IEnumerator<TSource> GetEnumerator()
		{
			return this.Clone();
		}
		IEnumerator IEnumerable.GetEnumerator()
		{
			return this.GetEnumerator();
		}
		public void Dispose()
		{
			if (this.enumerator != null)
			{
				this.enumerator.Dispose();
			}
			this.enumerator = null;
			this.current = default(TSource);
		}
		public bool MoveNext()
		{
			if (this.enumerator == null)
			{
				this.enumerator = this.source.GetEnumerator();
			}
			if (!this.enumerator.MoveNext())
			{
				return false;
			}
			this.current = this.enumerator.Current;
			return true;
		}
		public void Reset()
		{
			throw new NotImplementedException();
		}
	}
}
